Skip to content

Add API to statically assert signature of a Func#955

Merged
alexcrichton merged 3 commits into
bytecodealliance:masterfrom
alexcrichton:static-assert-func-signature
Feb 20, 2020
Merged

Add API to statically assert signature of a Func#955
alexcrichton merged 3 commits into
bytecodealliance:masterfrom
alexcrichton:static-assert-func-signature

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

This commit add a family of APIs to Func named getN where N is the
number of arguments. Each function will attempt to statically assert the
signature of a Func and, if matching, returns a corresponding closure
which can be used to invoke the underlying function.

The purpose of this commit is to add a highly optimized way to enter a
wasm module, performing type checks up front and avoiding all the costs
of boxing and unboxing arguments within a Val. In general this should
be much more optimized than the previous call API for entering a wasm
module, if the signature is statically known.

Comment thread crates/api/src/func.rs Outdated
This commit add a family of APIs to `Func` named `getN` where `N` is the
number of arguments. Each function will attempt to statically assert the
signature of a `Func` and, if matching, returns a corresponding closure
which can be used to invoke the underlying function.

The purpose of this commit is to add a highly optimized way to enter a
wasm module, performing type checks up front and avoiding all the costs
of boxing and unboxing arguments within a `Val`. In general this should
be much more optimized than the previous `call` API for entering a wasm
module, if the signature is statically known.
@alexcrichton alexcrichton force-pushed the static-assert-func-signature branch from 1082b47 to 4bb4086 Compare February 20, 2020 15:27
@alexcrichton alexcrichton merged commit 80b095f into bytecodealliance:master Feb 20, 2020
@alexcrichton alexcrichton deleted the static-assert-func-signature branch February 20, 2020 15:28
arkpar pushed a commit to paritytech/wasmtime that referenced this pull request Mar 4, 2020
This change should make the code more clear (and less code) when adding encodings for instructions with specific immediates; e.g., a constant with a 0 immediate could be encoded as an XOR with something like `const.bind(...)` without explicitly creating the necessary predicates. It has several parts:
* Introduce Bindable trait to instructions
* Convert all instruction bindings to use Bindable::bind()
* Add ability to bind immediates to BoundInstruction
This is an attempt to reduce some of the issues in bytecodealliance#955.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants